﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Dimok.Web.UI;

public partial class ExcelFromCache : System.Web.UI.Page {
	string ExcelReportKey { get { return Request["ExcelReportKey"]; } }
	string FileName { get { return Request["FileName"]+""; } }
	DataSet ExcelReportDataSet {
		get {
			if (ExcelReportKey + "" == "") throw new Exception("There is no ExcelReportKey in request.");
			return Context.Cache[ExcelReportKey] as DataSet;
		}
	}
	protected void Page_Load(object sender, EventArgs e) {
		var ds = ExcelReportDataSet as DataSet;
		if (ds == null) throw new Exception("There is no ExcelReport DataSet in session cache.");
		var dg = new DataGrid();
		dg.DataSource = ds;
		dg.DataBind();
		//var fileName = ds.Tables[0].TableName.Split(new[] { '.' }, StringSplitOptions.RemoveEmptyEntries).Last();
		dg.ToExcel(this,FileName);
	}
}
